import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)

// 富文本编辑器
import Vue2Editor from 'vue2-editor'
Vue.use(Vue2Editor)

Vue.config.productionTip = false
// 全局组件

import myCompontent from '@/components/index'
Vue.use(myCompontent)

import ImageUpload from '@/components/ImageUpload'
import FenYeQi from '@/components/fenyeqi'
Vue.component('ImageUpload', ImageUpload)
Vue.component('FenYeQi', FenYeQi)
// 自定义指令
Vue.directive('imgerror', {
  inserted(el, binding) {
    el.addEventListener('error', () => {
      // 图片地址错误时的处理
      el.src = binding.value
    })
    // 图片地址为空时的处理
    el.src = el.src || binding.value
  }
})
// mixin
import mixin from '@/mixin/checkPermission'
Vue.mixin(mixin)

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
